import request from '@/utils-shop/request'

// api地址
const api = {
  list: 'goods/list',
  add: 'goods/add',
  edit: 'goods/edit',
  detail: 'goods/detail',
  categoryList: 'category/list',
  categoryAdd: 'category/add',
  categoryEdit: 'category/edit',
  categoryDelete: 'category/delete',
}

// 商品列表
export const list = param => {
  return request.get(api.list, param)
}

// 商品详情
export const detail = goodsId => {
  return request.get(api.detail, { goodsId })
}

// 商品添加
export const add = param => {
  return request.post(api.add, param)
}

// 商品添加
export const edit = param => {
  return request.post(api.edit, param)
}

// 商品列表
export const categoryList = param => {
  return request.get(api.categoryList, param)
}


// 商品添加
export const categoryAdd = data => {
  return request.post(api.categoryAdd, {form: data})
}

// 商品编辑
export const categoryEdit = (categoryId, data) => {
  return request.post(api.categoryEdit, { categoryId, form: data })
}

// 分类删除
export const categoryDelete = categoryId => {
  return request.get(api.categoryDelete, { categoryId })
}